package com.scientific.research.gobang.controller;

import com.scientific.research.gobang.pojo.MatchMessage;
import com.scientific.research.gobang.pojo.SignMessage;
import com.scientific.research.gobang.service.MatchService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RequestMapping("Match")
@RestController//Rest是让所有方法的返回值都是JSON格式
public class MatchController {
    @Resource(name = "matchServiceImpl")
    MatchService matchService;

    @PostMapping("matchDataPass")
    public void matchDataPass(@RequestBody String soon) {
        matchService.matchDataPass(soon);
    }

    @PostMapping("changeMatchEndTime")
    public void changeMatchEndTime(@RequestBody MatchMessage match) {
        matchService.changeMatchEndTime(match);
    }

    @PostMapping("getUserMatchCode")
    public SignMessage getUserMatchCode(@RequestBody Map postData) {
        return matchService.getUserMatchCode(postData);
    }

    @PostMapping("userSubmitCode")
    public void userSubmitCode(@RequestBody Map signMessage) {
        matchService.userSubmitCode(signMessage);
    }

    @PostMapping("insertMatchUser")
    public String insertMatchUser(@RequestBody Map map) {
        return matchService.insertMatchUser(map);
    }

    @PostMapping("saveMatchMessage")
    public void saveMatchMessage(@RequestBody Map map) {
        matchService.saveMatchMessage(map);
    }

    @PostMapping("toUserMatch")
    public List<MatchMessage> toUserMatch(@RequestBody Map map) {
        return matchService.toUserMatch(map);
    }

    @PostMapping("toMatchResult")
    public MatchMessage toMatchResult(@RequestBody String id) {
        return matchService.toMatchResult(id);
    }

    @PostMapping("startMatch")
    public void startMatch(@RequestBody String soon) {
        matchService.startMatch(soon);
    }
}
